package apIExercise.exception;

import java.io.FileOutputStream;
import java.io.IOException;

public class AutoCloseableDemo {
    public static void main(String[] args) {
        /*
      FileOutputStream s=null;
      try {
          s=new FileOutputStream("a/a");
          s.write(5);
      }catch (Exception e){
          System.out.println("出现异常并解决,并写出");
      }finally {
          try {
              s.close();
          } catch (Exception e) {
              System.out.println("出现异常并解决，并关流");
          }
      }

         */
        System.out.println("从现在开始");
        try(
                FileOutputStream fos=new FileOutputStream("tt/a");
                ){
            fos.write(5);
        }catch (IOException e){
            System.out.println("出错并解决");
        }finally {
            System.out.println("每天一瓶快乐水");
        }
        System.out.println("到以后结束");
    }
}
